<?php

namespace Common\Model;
use Think\Model;

class PatientLifeStatusModel extends Model {

	protected $tableName = 'patient_life_status';

	protected $_validate = array(
    ['patient_id','require','病人id必须填',self::MUST_VALIDATE],
    ['heart_rate','require','必须填心率',self::MUST_VALIDATE],
    ['blood_pressure','require','血压',self::MUST_VALIDATE],
    ['oxygen_saturation','require','氧气',self::MUST_VALIDATE],
    ['breathing_rate','require','呼吸频率',self::MUST_VALIDATE],
    ['record_time','require','记录时间',self::MUST_VALIDATE],
  );

 	protected $_auto = array (
 		['create_time','time',self::MODEL_INSERT,'function'],
  );

  public function getPatientAllRecords($patient_id){
    if(!$patient_id || empty($patient_id) ){
      return false;
    }

    return $this->where(['patient_id'=>$patient_id])->select();
  }

  public function getPatientRecords($patient_id,$offset,$length){
    if(!$patient_id || empty($patient_id) ){
      return false;
    }

    return $this->where(['patient_id'=>$patient_id])->limit($offset,$length)->select();
  }

  public function getPatientRecordsCount($patient_id){
    return $this->where(['patient_id'=>$patient_id])->count();
  }

}